package com.eventbus;

import com.google.common.eventbus.DeadEvent;
import com.google.common.eventbus.Subscribe;

public class EventListener {
    //使用 @Subscribe注解 订阅消息
    @Subscribe
    public void listen(MyEvent event) {  //会同时监听子类
        System.out.println("Message:"+event.getMessage());
    }
    //可对应监听不同的消息类型
    @Subscribe
    public void listen(Integer event) {
        System.out.println("Integer:"+event);
    }
    // 死信消息
    @Subscribe
    public void listen(DeadEvent event) {
        System.out.println("死信消息,没有监听者:"+event.getEvent().toString());
    }
}
